
#ifndef HAL_SPI_H
#define HAL_SPI_H

#include "hal_types.h"
#include "spi_lld.h"

/*
typedef enum
{
	SPI_CHANNEL0 = 0,
	SPI_CHANNEL1 = 1,
	SPI_CHANNEL2 = 2,
	SPI_CHANNEL3 = 3,
	SPI_CHANNEL4 = 4,
	SPI_CHANNEL5 = 5
}spi_channel_en;
*/

typedef enum
{
	SPI_CPOL0_CPHA0 = 0,
	SPI_CPOL0_CPHA1 = 1,
	SPI_CPOL1_CPHA0 = 2,
	SPI_CPOL1_CPHA1 = 3
}spi_mode_en;

/*
typedef enum
{
	SPI_MASTER = 0,
	SPI_SLAVE  = 1
}spi_role_en;
*/

typedef enum
{
	SPI_DISABLE = 0,
	SPI_ENABLE  = 1
}spi_enabled_en;

typedef enum
{
	SPI_FAIL = 0,
	SPI_SUCCEE = 1,
	SPI_SLAVE_WAIT_CLOCK = 2
}spi_result_en;

typedef enum
{
	SPI_MSB = 0,
	SPI_LSB = 0
}spi_data_order_en;

void hal_spi_init(spi_controller_t channel ,uint32_t hz ,spi_pcs_polarity_t cs_level ,spi_mode_en mode ,enabled_en en);
result_en hal_spi_write(spi_controller_t channel ,const uint8_t *send_buff ,uint8_t * rece_buff);
result_en hal_spi_writes(spi_controller_t channel ,const uint8_t *send_buff ,uint8_t * rece_buff ,uint16_t len);
void hal_spi_enabled(spi_controller_t channel ,enabled_en en);
void hal_spi_role(spi_controller_t channel ,spi_functional_mode_t role);
spi_functional_mode_t hal_spi_get_role(spi_controller_t channel);

#endif 
